//
//  AdvertisementView.m
//  quxiangtao
//
//  Created by xbmios on 2018/7/4.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "AdvertisementView.h"

@interface AdvertisementView ()

@property (strong, nonatomic) UIImageView *adverIV;

@end

@implementation AdvertisementView

- (instancetype)init {
    
    self = [super init];
    
    if (self) {
        
        [self addSubview:self.adverIV];
        
    }
    
    return self;
    
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    __weak typeof(self) weakSelf = self;
    [self.adverIV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.width.mas_equalTo(jisuan(710));
        make.height.mas_equalTo(jisuan(240));
        
    }];
    
}

#pragma mark -广告点击事件
- (void)adverGestureClick:(UIGestureRecognizer *)recognizer {
    
    NSLog(@"图片点击事件");
    
}

#pragma mark -lazy
- (UIImageView *)adverIV {
    
    if (!_adverIV) {
        
        _adverIV = [[UIImageView alloc] init];
        _adverIV.contentMode = UIViewContentModeScaleAspectFit;
        _adverIV.backgroundColor = Colorf2f2f2;
        _adverIV.image = [UIImage imageNamed:@"advertisementBG"];
        
        _adverIV.userInteractionEnabled = YES;
        UITapGestureRecognizer *adverGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(adverGestureClick:)];
        [_adverIV addGestureRecognizer:adverGesture];
        
    }
    
    return _adverIV;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
